<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <button>发送请求</button>
        <script type="text/javascript">

            const btn = document.querySelector("button");

            btn.onclick = function(){
                const xhr = new XMLHttpRequest();
                xhr.open("GET","http://127.0.0.1:9000/cors-server");
                xhr.send();
                xhr.onreadystatechange = function(){
                    if(xhr.readyState === 4){
                        if(xhr.status >= 200 && xhr.status <300){
                            alert(xhr.response);
                        };
                    };
                };
            };


        </script>
    </body>
</html>